<template>
  <div class="mx-container">
    <zz-sub-nav :list="list" :index.sync="index">
      <div class="sub-nav-content">
        <div>
          <div class="details-title">{{$t('zz.hot_menu')}}</div>
          <div class="flex-4 flex-pc-2">
            <div class="flex-4-item" v-for="(it, i) in comboList" :key="i">
              <div class="clound-card">
                <div class="clound-card-title">
                  <h6>{{ it.name }}</h6>
                  <p style="height: 75px;">{{ it.intro }}</p>
                  <!-- -->
                </div>
                <div class="clound-card-body">
                  <table class="clound-body-table">
                    <tr>
                      <th>{{$t('zz.basics.cloud.meal.systemdisk')}} :</th>
                      <td>{{ it.disk }}</td>
                    </tr>
                    <tr>
                      <th>{{$t('zz.basics.cloud.meal.broadband')}} :</th>
                      <td>{{ it.broadband }} Mbps</td>
                    </tr>
                    <tr>
                      <th>{{$t('zz.basics.cloud.meal.flow')}} :</th>
                      <td>{{$t('zz.basics.cloud.meal.unlimitedFlow')}}</td>
                    </tr>
                    <tr>
                      <th valign="top">{{$t('zz.basics.cloud.meal.territory')}} :</th>
                      <td>{{$t('zz.hongkong')}}、{{$t('zz.china')}}、{{$t('zz.us')}}</td>
                    </tr>
                  </table>
                  <div class="select-wrap">
                    <div
                      :class="{ active: activeCombo[i] === 'month' }"
                      @click="handleChange(i, 'month')"
                    >
                      {{$t('zz.basics.cloud.meal.payType.month')}}
                    </div>
                    <div
                      :class="{ active: activeCombo[i] === 'year' }"
                      @click="handleChange(i, 'year')"
                    >
                      {{$t('zz.basics.cloud.meal.payType.year')}}
                    </div>
                  </div>
                  <div class="clound-card-money" v-if="activeCombo[i] === 'month'">
                    {{priceUnit}}<span class="money-importent">{{ it.monthMoney | conversionPrice}}</span
                    >/{{$t('zz.month')}}
                    <s>{{$t('zz.o_price')}} {{priceUnit}}{{ it.monthMoneyBefore | conversionPrice}}/{{$t('zz.year')}}</s>
                  </div>
                  <div class="clound-card-money" v-else>
                    {{priceUnit}}<span class="money-importent">{{ it.yearMoney | conversionPrice }}</span
                    >/{{$t('zz.year')}}
                    <s>{{$t('zz.o_price')}} {{priceUnit}}{{ it.yearMoneyBefore | conversionPrice }}/{{$t('zz.year')}}</s>
                  </div>
                </div>
                <div class="clound-card-footer">
                  <div class="zz-btn btn-empty btn-blue" @click="handleBuy(it)">{{$t('zz.buy_now')}}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div>
          <div class="details-title">{{$t('zz.functional_characteristics')}}</div>
          <div class="flex-2">
            <div
              class="flex-2-item"
              v-for="(item, index) in list1"
              :key="index"
            >
              <sim-card :title="item.title" :content="item.content"></sim-card>
            </div>
          </div>
        </div>
        <div>
          <div class="details-title">{{$t('zz.product_superiority')}}</div>
          <div class="flex-2">
            <div
              class="flex-2-item"
              v-for="(item, index) in list2"
              :key="index"
            >
              <sim-card :title="item.title" :content="item.content"></sim-card>
            </div>
          </div>
        </div>
      </div>
    </zz-sub-nav>
  </div>
</template>

<script>
import SubNav from "@/components/SubNav/index.vue";
import ZzCard from "@/components/ZzCard";
import SimCard from "@/components/SimCard";
import Bus from '@/bus.js'
import { priceUnit, showPrice } from '@/utils/branch'

export default {
  data() {
    return {
      index: 1,
      subIndex: 1,
      height: 230,
      titleSize: 20,
      activeCombo:['month','month','month','month'],
      priceUnit,
      
    };
  },

  components: {
    "zz-sub-nav": SubNav,
    ZzCard,
    SimCard,
  },
  props: {},
  mounted() {},
  computed: {
    activeItem: function () {
      let activeItem = this.list.find((v) => v.index == this.index);
      console.log(this.list[this.index]);
      this.subIndex = activeItem.child ? activeItem.child[0].index : 1;
      return activeItem;
    },

    list: function(){ return[
        { name: this.$t('zz.hot_menu'), index: 1, title: this.$t('zz.hot_menu') },
        { name: this.$t('zz.functional_characteristics'), index: 2, title: this.$t('zz.functional_characteristics') },
        { name: this.$t('zz.product_superiority'), index: 3, title: this.$t('zz.product_superiority') },
      ]
    },
      list1: function(){ return [
        {
          title: this.$t('zz.basics.cloud.funtion.1.title'),
          content: this.$t('zz.basics.cloud.funtion.1.des'),
        },
        {
          title: this.$t('zz.basics.cloud.funtion.2.title'),
          content: this.$t('zz.basics.cloud.funtion.2.des'),
        },
        {
          title: this.$t('zz.basics.cloud.funtion.3.title'),
          content: this.$t('zz.basics.cloud.funtion.3.des'),
        },
        {
          title: this.$t('zz.basics.cloud.funtion.4.title'),
          content: this.$t('zz.basics.cloud.funtion.4.des'),
        },
      ]
      },
      list2: function(){ return [
        {
          title: this.$t('zz.basics.cloud.product.1.title'),
          content: this.$t('zz.basics.cloud.product.1.des'),
        },
        {
          title: this.$t('zz.basics.cloud.product.2.title'),
          content: this.$t('zz.basics.cloud.product.2.des'),
        },
        {
          title: this.$t('zz.basics.cloud.product.3.title'),
          content: this.$t('zz.basics.cloud.product.3.des'),
        },
        {
          title: this.$t('zz.basics.cloud.product.4.title'),
          content: this.$t('zz.basics.cloud.product.4.des'),
        },
        {
          title: this.$t('zz.basics.cloud.product.5.title'),
          content: this.$t('zz.basics.cloud.product.5.des'),
        },
        {
          title: this.$t('zz.basics.cloud.product.6.title'),
          content: this.$t('zz.basics.cloud.product.6.des'),
        },
        {
          title: this.$t('zz.basics.cloud.product.7.title'),
          content: this.$t('zz.basics.cloud.product.7.des'),
        },
        {
          title: this.$t('zz.basics.cloud.product.8.title'),
          content: this.$t('zz.basics.cloud.product.8.des'),
        },
      ]
      },
      comboList: function(){ return [
        {
          name: `1${this.$t('zz.basics.cloud.meal.name')}1G`,
          disk: "40G",
          broadband: 2,
          monthMoney: 66.8,
          monthMoneyBefore: 80,
          yearMoney: 668,
          yearMoneyBefore: 800,
          intro: this.$t('zz.basics.cloud.meal.1.des'),
        },
        {
          name: `2${this.$t('zz.basics.cloud.meal.name')}4G`,
          disk: "40G",
          broadband: 2,
          monthMoney: 138.8,
          monthMoneyBefore: 166,
          yearMoney: 1388,
          yearMoneyBefore: 1660,
          intro: this.$t('zz.basics.cloud.meal.2.des'),
        },
        {
          name: `4${this.$t('zz.basics.cloud.meal.name')}8G`,
          disk: "40G",
          broadband: 2,
          monthMoney: 296.8,
          monthMoneyBefore: 356,
          yearMoney: 2968,
          yearMoneyBefore: 3560,
          intro: this.$t('zz.basics.cloud.meal.3.des'),
        },
        {
          name: `8${this.$t('zz.basics.cloud.meal.name')}8G`,
          disk: "40G",
          broadband: 2,
          monthMoney: 366.8,
          monthMoneyBefore: 440,
          yearMoney: 3668,
          yearMoneyBefore: 4400,
          intro: this.$t('zz.basics.cloud.meal.4.des'),
        },
      ]
    }
  },
  watch: {},
  methods: {
    navClick(a_item) {
      console.log(a_item);
      this.subIndex = a_item.index;
    },
    handleChange(a_i, a_str) {
      console.log(a_i, a_str);
      // if(this.activeCombo[a_i] === a_str) return false
      this.activeCombo.splice(a_i,1,a_str)
    },
    handleBuy(a_it){
      console.log(1);
      Bus.$emit('serveFun')
    }
  },
  destroyed() {},
};
</script>
<style lang='scss' scoped>
@import "@/style/variables.scss";

.sub-nav-content {
  padding: 12px 48px;
  flex: 1;
  width: 100%;
  .pro-title {
    color: $color;
    font-size: 20px;
    padding: 20px 45px;
    border-bottom: 1px solid $border;
  }
  .pro-intro-wrap {
    padding: 30px 48px;
  }
  img {
  }
  & > ul {
    width: auto;
    margin: 0 auto;
  }
}
.son-pro-wrap {
  display: flex;
  // justify-content: space-between;
  margin-top: 48px;
  flex-wrap: wrap;
  & > div {
    width: 240px;
    margin-right: 40px;
  }
}
.pro-pailie-wrap {
  .card-wrap {
    margin-top: 30px;
    display: flex;
    flex-wrap: wrap;
    & > div {
      width: 40%;
      margin: 0 5% 30px;
      img {
        margin-top: 0;
        width: 32px;
        margin-right: 10px;
      }
      h6 {
        font-size: 22px;
        line-height: 32px;
        margin: 15px 0 20px;
      }
      p {
        font-size: 14px;
        line-height: 25px;
      }
    }
  }
}
.business-wrap {
  padding: 50px 0;
  h6 {
    font-size: 16px;
    margin: 50px 0 25px;
  }
  ul {
    padding-left: 25px;
    li {
      color: rgba(59, 59, 59, 1);
      font-size: 14px;
      line-height: 200%;
    }
  }
  p {
    font-size: 14px;
  }
}
.list-has-poi {
  list-style-type: disc;
  li {
    list-style-type: disc;
  }
}
.flex-2 {
  .flex-2-item {
    margin-right: 50px;
    &:nth-child(2n) {
      margin-right: 0;
    }
  }
}

.clound-card {
  padding: 25px 12px;
  border-right: 1px solid $border;
  .clound-card-title {
    border-bottom: 1px solid $border;
    padding-bottom: 15px;
    h6 {
      text-align: center;
      font-weight: bold;
      font-size: 20px;
      margin: 0 0 15px;
    }
    p {
      line-height: 150%;
      text-align: center;
    }
  }
  .clound-card-body {
    padding: 25px 0 10px;
    .clound-body-table {
      margin: 0 auto;
      tr {
        th,
        td {
          line-height: 25px;
          text-align: right;
          width: 40%;
          font-weight: normal;
          color: #999;
          padding-bottom: 10px;
        }
        td {
          width: 50%;
          text-align: left;
          padding-left: 10px;
          font-weight: bold;
          color: #000;
        }
      }
    }
    .select-wrap {
      border: 1px solid $blue;
      border-radius: 3px;
      display: flex;
      color: $blue;
      line-height: 30px;
      width: 85%;
      margin: 10px auto;
      div {
        position: relative;
        width: 50%;
        cursor: pointer;
        text-align: center;
        // &::after{
        //   position: absolute;
        //   display: block;
        //   content: '6折';
        //   color: #C5924B;
        //   right: 2px;
        //   top: 0;
        //   height: 20px;
        //   border-radius: 4px;
        //   line-height: 20px;
        //   padding: 0 5px;
        //   font-size: 10px;
        //   background:  linear-gradient(to right, #ECC184, #F6E3C7);
        //   transform: translate(0, -10px) scale(.8);
        // }
        &.active {
          background-color: $blue;
          color: #fff;
        }
      }
    }
    .clound-card-money {
      text-align: center;
      color: $red;
      margin-top: 20px;
      .money-importent {
        font-weight: bold;
        color: $red;
        font-size: 20px;
      }
      s {
        color: $subColor;
      }
    }
  }

  .clound-card-footer {
    width: 85%;
    margin: 0 auto;
  }
}

.flex-4 {
  margin: 0 -15px;
  .flex-4-item {
    margin-right: 0;
    width: 25%;
    &:last-child {
      .clound-card {
        border-right: none;
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .clound-card{
    .clound-card-body{
      .clound-body-table{
        tr{
          th{
            width: 35%;
          }
        }
      }
      
    }
 

  }
  .flex-4 {
    &.flex-pc-2 {
      .flex-4-item {
        width: 50%;
        &:nth-child(2n) {
          .clound-card {
            border-right: none;
          }
        }
        &:nth-child(-n+2) {
          .clound-card {
            border-bottom: 1px solid $border;
          }
        }
      }
    }
  }
}
</style>